<?php

namespace app\index\controller;

use app\common\controller\Send;
use think\Controller;
use think\Db;

class Register extends Controller
{
    // 加载手机注册
    public function index()
    {
        return view('register/index');
    }

    public function register()
    {
        $data = input('post.');

        // 处理数据
        unset($data['repass']);
        $data['pass'] = md5($data['pass']);
        $data['regtime'] = date('Y-m-d H:i:s');

        // 插入数据
        $res = Db::name('huser')
            ->insert($data);

        if ($res > 0) {
            return $this->success('注册成功!','index/login/index');
        } else {
            return $thid->error('注册失败!请重新注册!');
        }

    }

    // 加载邮箱登录
    public function email()
    {
        return view('register/email');
    }

    // 获取短信验证码
    public function getTelCode()
    {
//        $result = sendTemplateSMS('17754013833',array('888888','2'));
        $result = sendTemplateSMS('17754013833',array('888888','2'),'1');
        return $result;
    }


}
